package com.netty.services.impl;

import com.netty.mappers.UserMapper;
import com.netty.model.entity.User;
import com.netty.services.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserByUserId(Integer userId) {
        return userMapper.getUserByUserId(userId);
    }

    @Override
    @Transactional
    public int addUser(User user) {

        userMapper.addUser(user);

        return user.getUserId();
    }

    @Override
    public List<User> getAllUser() {
        return userMapper.getAllUser();
    }
}
